#include "cpu/exec/template-start.h"

#define instr adc

static void do_execute () {
	DATA_TYPE result = op_dest->val + op_src->val + cpu.eflags.CF;
	OPERAND_W(op_dest, result);

	cpu.eflags.CF = (result < op_dest->val);

    cpu.eflags.SF = result >> (DATA_BYTE*8 -1);

    int a = op_dest->val >> (DATA_BYTE*8 - 1);
    int b = op_src->val >> (DATA_BYTE*8 - 1);		
		
    cpu.eflags.OF = (a == b) && (b != cpu.eflags.SF);
    cpu.eflags.ZF = !result;
	// 结果的最低有效字节包含偶数个1 为1
    result ^= result >>4;
	result ^= result >>2;
	result ^= result >>1;
	cpu.eflags.PF = !(result & 1);
    //D3到D4是否进位
    if(( (op_dest->val & 0xf) + (op_src->val & 0xf)  + cpu.eflags.CF) >> 4) cpu.eflags.AF = 1;
    else cpu.eflags.AF = 0;

	print_asm_template2();
}

make_instr_helper(i2rm)
#if DATA_BYTE == 2 || DATA_BYTE == 4
make_instr_helper(si2rm)
#endif

make_instr_helper(r2rm)
make_instr_helper(rm2r)
#include "cpu/exec/template-end.h"
